package net.m2technologies.open_arm.transaction;

import org.opengroup.arm40.transaction.ArmID;
import org.opengroup.arm40.transaction.ArmTransactionFactory;
import org.opengroup.arm40.transaction.ArmUser;

/**
 * Copyright 2005 Mark Masterson<br> <br> Licensed under the Apache License, Version 2.0 (the "License");<br> you may
 * not use this file except in compliance with the License.<br> You may obtain a copy of the License at<br> <br>
 * http://www.apache.org/licenses/LICENSE-2.0<br> <br> Unless required by applicable law or agreed to in writing,
 * software<br> distributed under the License is distributed on an "AS IS" BASIS,<br> WITHOUT WARRANTIES OR CONDITIONS
 * OF ANY KIND, either express or implied.<br> See the License for the specific language governing permissions and<br>
 * limitations under the License.<br>
 * <p/>
 * <p>Description: </p>
 *
 * @author Mark Masterson
 * @version 0.010
 */
public class ArmUserImpl extends UniqueObjectImpl implements ArmUser {

    private final String userName;

    public ArmUserImpl(final ArmID id, final String userName, final ArmTransactionFactory creatingFactory) {
        super(id, creatingFactory);
        this.userName = userName;
    }

    public String getName() {
        return this.userName;
    }

    public boolean equals(final Object o) {
        if (this == o) return true;
        if (!(o instanceof ArmUserImpl)) return false;
        if (!super.equals(o)) return false;

        final ArmUserImpl armUser = (ArmUserImpl) o;

        return !(null != userName ? !userName.equals(armUser.userName) : null != armUser.userName);

    }

    public int hashCode() {
        int result = super.hashCode();
        result = HASH_CODE_MAGIC_NUMBER * result + (null != userName ? userName.hashCode() : 0);
        return result;
    }

}
